using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Printing ;
using System.Windows.Forms;
class PrintableForm: Form
{
	
	public PrintableForm()
	{
		Text = "Printable Form";
		BackColor = SystemColors.Window;
		ForeColor = SystemColors.WindowText;
		ResizeRedraw = true;
	}
	protected override void OnPaint(PaintEventArgs pea)
	{
		DoPage(pea.Graphics, ForeColor,
			ClientSize.Width, ClientSize.Height);
	}
	protected override void OnClick(EventArgs ea)
	{
		PrintDocument prndoc = new PrintDocument();
		prndoc.DocumentName = Text;
		prndoc.PrintPage +=
			new PrintPageEventHandler(PrintDocumentOnPrintPage);
		prndoc.Print();
	}
	void PrintDocumentOnPrintPage(object obj, PrintPageEventArgs ppea)
	{
		Graphics grfx = ppea.Graphics;
		SizeF sizef = grfx.VisibleClipBounds.Size;
		DoPage(grfx, Color.Black, (int)sizef.Width, (int)sizef.Height);
	}
	protected virtual void DoPage(Graphics grfx, Color clr, int cx, int
		cy)
	{
		Pen pen = new Pen(clr);
		grfx.DrawLine(pen, 0, 0, cx - 1, cy - 1);
		grfx.DrawLine(pen, cx - 1, 0, 0, cy - 1);
	}
}


class StringAlignmentRectangle: PrintableForm
{
	public new static void Main()
	{
		Application.Run(new StringAlignmentRectangle());
	}
	public StringAlignmentRectangle()
	{
		Text = "String Alignment (RectangleF in DrawString)";
	}
	protected override void DoPage(Graphics grfx, Color clr, int cx, int
		cy)
	{
		Brush brush = new SolidBrush(clr);
		RectangleF rectf = new RectangleF(0, 0, cx, cy);
		string[] strAlign = { "Near", "Center", "Far" };
		StringFormat strfmt = new StringFormat();
		for (int iVert = 0; iVert < 3; iVert++)
			for (int iHorz = 0; iHorz < 3; iHorz++)
			{
				strfmt.LineAlignment = (StringAlignment)iVert;
				strfmt.Alignment = (StringAlignment)iHorz;
				grfx.DrawString(
					String.Format("LineAlignment = {0}\nAlignment = {1}",
					strAlign[iVert], strAlign[iHorz]),
					Font, brush, rectf, strfmt);
			}
	}
}